package com.pipodi.itasamobile.connections;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class ConnectionForImg {

	public ConnectionForImg(){
		super();
	}
	
	public static Bitmap getPhotoFromURL(String URL){
		URL photo_URL;
		try {
			photo_URL = new URL(URL);
			HttpURLConnection photo_connection = (HttpURLConnection) photo_URL.openConnection();
			photo_connection.setDoInput(true);
			photo_connection.connect();
			InputStream input = photo_connection.getInputStream();
			Bitmap photo = BitmapFactory.decodeStream(input);
			photo_connection.disconnect();
			return photo;
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
